package com.xuetang9.fujian.socketdemo.tcpdemo.onetomore;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * @author: fujian
 * @description:
 * @date: 2021/5/10 9:27
 * @version: V1.0
 * @package: com.xuetang9.fujian.socketdemo.tcpdemo.onetomore
 **/
public class MusicTask implements Runnable{
    private File music;

    public MusicTask(File music) {
        this.music = music;
    }

    @Override
    public void run() {
        Player player = null;
        try {
            player = new Player(new FileInputStream(music));
            player.play();
        } catch (JavaLayerException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            player.close();
        }
    }
}
